package com.heima.article.listener;

import com.alibaba.fastjson.JSON;
import com.heima.article.service.ApArticleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author Lijx
 * @Date 2024-07-29 11:20
 */
@Component
@Slf4j
public class ArticleListener {
    @Autowired
    private ApArticleService apArticleService;

    @KafkaListener(topics = "article_up_or_down")
    public void downOrUp(String msg){
        log.info("接收到数据，{}",msg);
        Map map = JSON.parseObject(msg, Map.class);

        //更新app文章上下架
        apArticleService.downOrUp(map);
    }
}
